package com.yzcrm.erp.kms.controller;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.paragetter.Para;
import com.yzcrm.common.annotation.Permissions;
import com.yzcrm.erp.kms.service.KmsReportService;
import com.yzcrm.swagger.annotation.ActionApi;
import com.yzcrm.swagger.annotation.Api;
import com.yzcrm.swagger.annotation.Param;
import com.yzcrm.swagger.annotation.Params;
import com.yzcrm.utils.R;

/**
 * @author jiang.xue
 * 课程管理
 */
@Api(remark = "知识库报表")
public class KmsReportController extends Controller{

    @Inject
    private KmsReportService reportService;

    /**
     * 知识库学习报表
     */
    @Permissions({"kms:report:student_report"})
    @ActionApi(summary = "知识库学习报表", remark="知识库学习报表")
    @Params({
            @Param(name="userName", remark="用户名", dataType="String",required=false),
            @Param(name="deptName", remark="部门名", dataType="String",required=false),
            @Param(name="courseName", remark="课程名", dataType="String",required=false),
            @Param(name="page", remark="页码 1开始", dataType="int", defaultValue="", required=false),
            @Param(name="limit", remark="每页数据条数", dataType="int", defaultValue="", required=false)
    })
    public void report(@Para("userName") String userName, @Para("deptName") String deptName, @Para("courseName") String courseName,
            @Para("page") Integer page, @Para("limit") Integer limit) {

//        JSONObject jsonObject = basePageRequest.getJsonObject().fluentPut("type", CrmEnum.KMS_COURSE.getType());
//        basePageRequest.setJsonObject(jsonObject);
//        renderJson(courseService.filterConditionAndGetPageList(basePageRequest));
        renderJson(reportService.report(userName, deptName, courseName, page, limit));
    }

    /**
     * 知识库学习报表 表头信息
     */
    @Permissions({"kms:report:student_report"})
    @ActionApi(summary = "知识库学习报表 表头信息", remark="知识库学习报表 表头信息")
    public void queryReportListHead() {

        renderJson(R.ok().put("data", reportService.queryReportListHead()));
    }


    /**
     * 课程内容学习进度
     */
    @Permissions({"kms:report:student_report"})
    @ActionApi(summary = "课程内容学习进度", remark="课程内容学习进度")
    @Params({
            @Param(name="userId", remark="用户Id", dataType="Long",required=true)
    })
    public void reportCourse(@Para("userId") Long userId) {

        renderJson(reportService.reportCourse(userId));
    }

}
